<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>使用标签选择器</title>
<script type="text/javascript" src="jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(e) {
    var light=$("input[name='light']");
	alert(light.length);
	var offlight=$("#content input.off");  //在ID选择器后，使用标签选择器配合类选择器
    var lightbutton = $('#content #lightbutton');	 //在ID选择器中用ID选择器也会很慢
});
</script>
</head>

<body>
<div id="content">
 <form method="post" action="/">
  <h2>交通信号灯</h2>
  <ul id="tagdemo">
    <li><input type="radio" class="on" name="light" value="red" /> 红灯</li>
    <li><input type="radio" class="off" name="light" value="yellow" /> 黄灯</li>
    <li><input type="radio" class="off" name="light" value="green" /> 绿灯</li>
  </ul>
 <input class="button" id="lightbutton" type="submit" value="选中" />
</form>
</div>
</body>
</html>
